#pragma once
#include <COMUTIL.H>
//#include "ado.h"
//#include "utility.h"


struct POS
{ short row;
  short col;
};



class tdkTable
{
protected:
    CMap<int,const int&,CString,LPCTSTR>   m_nameMap;
	CMap<CString,LPCTSTR,int ,int&>   m_indexMap;
	CMap<int,int,_variant_t *,_variant_t *>   m_tdkMap;
	int      m_row;
	int      m_col;

public:
	CString m_name;

//static BOOL IsVarEqual(VARIANT v1,VARIANT v2);


public:
 tdkTable();
~tdkTable(); 

int      AddColumn(const CString& sColName);
bool     ChangeName(const CString& sColNameOld,const CString& sColNameNew);
//int      FindInColumn(int nCol,int nValue);
VARIANT& operator[](POS& pos);
BOOL     DeleteAt(POS& pos);
BOOL     DeleteColumn(const CString &sColName);
//int      FindRow(CString sColName,int     nValue);
//int      FindRow(CString sColName,CString sValue);


//CString  GetAt(int row,const CString& colName);
void     SetColumnName(int nCol,const CString& str);
CString  GetColumnName(int nCol);

int      GetRowCount();
int      GetColCount();
int      GetColumnIndex(const CString& colName);
void     SetItemText(int row,const CString& sCol,const CString& strItem);
void     SetItemText(int row,int col,const CString& strItem);
void     SetItemInt(int row,int col,int nItem);
bool     SetItemDouble(int row,const CString& colName,double d);
bool     SetItemInt(int row,const CString& sCol,int nItem);

//double   GetItemDouble(int row,int col,double defValue=0);
//double   GetItemDouble(int row,const CString& sCol,double defValue=0);

//CString  GetItemText(int row,const CString& colName);
//CString  GetItemText(int row,int col);
//int      GetItemInt(int row,int col,int defValue=INT_MIN);
//int      GetItemInt(int row,const CString& colName,int defValue=INT_MIN);

void     RemoveAll();
void     RemoveContents();
//GetItemIntBOOL     IsRowEmpty(int Row);

//_variant_t *  GetAt(int nRow,int nCol);
void          SetAt(int nRow,int nCol,_variant_t* pVar);
};


//class CAdoField
//{
//public: 
//	tdkTable m_tableFieldInfo;
//	CString m_sFields,m_sValues,m_sFieldsValues;
//
//	bool  Open(_ConnectionPtr cn,CString sTableName);
//	bool  FormatValue(CString sField,CString& sValue,_variant_t* vValue);
//	bool  Add(CString sField,LPCTSTR sValue,_variant_t* vValue=NULL);
//	bool  Add(CString sField,int nValue);
//	bool  VarToSqlStr(_variant_t& var,VARTYPE vtType,int maxSize,CString& str); 
//
//};

